import { App } from 'vue'
import xtxMore from './more/index.vue'
import { useIntersectionObserver } from '@vueuse/core'
export default {
  install (app: App) {
    app.component(xtxMore.name, xtxMore)
    //图片懒加载
    app.directive('lazy', {
      mounted (el, binding) {
        const { stop } = useIntersectionObserver(
          el,
          ([{ isIntersecting }]) => {
            if (isIntersecting) {
              el.src = binding.value
              stop()
            }
          },
          { threshold: 0 }
        )
      }
    })
  }
}
